package com.genexususa.eo.bing.data.results;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.BatchError;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.EditorialError;
import com.genexususa.eo.bing.data.GxItemException;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Bing_TargetResults")
public class GxTargetResults extends GxGeneralResults {
    @XmlElement(name = "TargetResultCollection")
    public GxTrackingIdResults targetResultCollection;
    @XmlElement(name = "CampaignAssociationResultCollection")
    public GxTargetIdCampaignIdResults campaignAssociationResultCollection;
    @XmlElement(name = "AdGroupAssociationResultCollection")
    public GxTargetIdAdGroupIdResults adGroupAssociationResultCollection;

    public GxTargetResults() {
        super();
    }

    public GxTrackingIdResults getTargetResultCollection() {
        return targetResultCollection;
    }

    public GxTargetIdCampaignIdResults getCampaignAssociationResultCollection() {
        return campaignAssociationResultCollection;
    }

    public GxTargetIdAdGroupIdResults getAdGroupAssociationResultCollection() {
        return adGroupAssociationResultCollection;
    }

    public void setTargetResultCollection(GxTrackingIdResults targetResultCollection) {
        this.targetResultCollection = targetResultCollection;
    }

    public void setCampaignAssociationResultCollection(GxTargetIdCampaignIdResults campaignAssociationResultCollection) {
        this.campaignAssociationResultCollection = campaignAssociationResultCollection;
    }

    public void setAdGroupAssociationResultCollection(GxTargetIdAdGroupIdResults adGroupAssociationResultCollection) {
        this.adGroupAssociationResultCollection = adGroupAssociationResultCollection;
    }

    public void updateError(boolean checkTarget) {
        if (((this.targetResultCollection == null || this.targetResultCollection.hasError) && checkTarget) ||
            this.campaignAssociationResultCollection == null || this.campaignAssociationResultCollection.hasError ||
            this.adGroupAssociationResultCollection == null || this.adGroupAssociationResultCollection.hasError) {
            this.hasError = true;
        }
    }

    @Override
    public void addGxExceptionError(GxItemException error, int index) {
    }

    @Override
    public void addBatchError(BatchError error) {
    }

    @Override
    public void addEditorialError(EditorialError error) {
    }
}
